/*
 * For legal stuff see the file COPYRIGHT
 */
#import "AppIconView.h"

@implementation AppIconView


/* Pass in a size and a subclass of View */
- initFrame:(const NXRect *)frameRect sourceView:obj 
{
	[super initFrame:frameRect];
 	sourceWindow = [obj window];
	[obj getFrame:&sourceRect];
	return self;
}
    
- drawSelf:(const NXRect *)rects :(int)count
{
	NXPoint	point = {9.0, 3.0};
	id bitmap, image;
    
#ifdef ERASE_BACKGROUND
	NXPoint	origin = {0.0, 0.0};
	[[NXImage findImageNamed:"NXAppTile"] composite:NX_SOVER toPoint:&origin];
#endif
	
	/* Read the bits from the window */
	[[sourceWindow contentView] lockFocus];
	bitmap = [[NXBitmapImageRep alloc] initData:NULL fromRect:&sourceRect];
	[[sourceWindow contentView] unlockFocus];
	[sourceWindow display];

	if (bitmap)
	{
		image=[[NXImage alloc] initSize:&sourceRect.size];		
		[image useRepresentation:bitmap];
		[image composite:NX_SOVER toPoint:&point];
		[image free];
	}
	else
		[bitmap free];
	return self;
}

@end
